package com.wodsy.phoenix.dataobject.goodsc.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

/**
 * TbFreightTemplate entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "tb_freight_template", catalog = "goodsc")
public class FreightTemplate implements java.io.Serializable {

	// Fields
	private static final long serialVersionUID = 1L;
	
	private Integer id;
	private Integer shipmentsOrigin;  //发货地对应的城市字典表的最下一级的城市id
	private Date addTime; 				//添加时间
	private Integer inRange; 			//重量范围
	private Integer inRangePrice;		//在重量范围内的价格
	private Integer outRangePrice;		//超过重量范围，每增加的重量的价格
	private Integer outRangeWeight;		//超过重量范围，每增加的重量
	private boolean isEnable;			//是否启用模版,0:启用；1：未启用
	private Integer shopId;			//店铺id
	private String name;			//模版名称
	private Date updateTime;		//更新时间

	private Set<FreightTemplateDestination> freightTemplateDestination = new HashSet<FreightTemplateDestination>();
	
	// Constructors
	
	/** default constructor */
	public FreightTemplate() {
	}

	/** minimal constructor */
	public FreightTemplate(Integer shipmentsOrigin, Date addTime,
			Integer inRange, Integer inRangePrice, Integer outRangePrice,
			Integer outRangeWeight, boolean isEnable, Integer shopId, String name) {
		this.shipmentsOrigin = shipmentsOrigin;
		this.addTime = addTime;
		this.inRange = inRange;
		this.inRangePrice = inRangePrice;
		this.outRangePrice = outRangePrice;
		this.outRangeWeight = outRangeWeight;
		this.isEnable = isEnable;
		this.shopId = shopId;
		this.name = name;
	}

	/** full constructor */
	public FreightTemplate(Integer shipmentsOrigin, Date addTime,
			Integer inRange, Integer inRangePrice, Integer outRangePrice,
			Integer outRangeWeight, boolean isEnable, Integer shopId,
			String name, Date updateTime) {
		this.shipmentsOrigin = shipmentsOrigin;
		this.addTime = addTime;
		this.inRange = inRange;
		this.inRangePrice = inRangePrice;
		this.outRangePrice = outRangePrice;
		this.outRangeWeight = outRangeWeight;
		this.isEnable = isEnable;
		this.shopId = shopId;
		this.name = name;
		this.updateTime = updateTime;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "increment")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "shipments_origin", nullable = false)
	public Integer getShipmentsOrigin() {
		return this.shipmentsOrigin;
	}

	public void setShipmentsOrigin(Integer shipmentsOrigin) {
		this.shipmentsOrigin = shipmentsOrigin;
	}

	@Column(name = "add_time", nullable = false, length = 19)
	public Date getAddTime() {
		return this.addTime;
	}

	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}

	@Column(name = "in_range", nullable = false)
	public Integer getInRange() {
		return this.inRange;
	}

	public void setInRange(Integer inRange) {
		this.inRange = inRange;
	}

	@Column(name = "in_range_price", nullable = false)
	public Integer getInRangePrice() {
		return this.inRangePrice;
	}

	public void setInRangePrice(Integer inRangePrice) {
		this.inRangePrice = inRangePrice;
	}

	@Column(name = "out_range_price", nullable = false)
	public Integer getOutRangePrice() {
		return this.outRangePrice;
	}

	public void setOutRangePrice(Integer outRangePrice) {
		this.outRangePrice = outRangePrice;
	}

	@Column(name = "out_range_weight", nullable = false)
	public Integer getOutRangeWeight() {
		return this.outRangeWeight;
	}

	public void setOutRangeWeight(Integer outRangeWeight) {
		this.outRangeWeight = outRangeWeight;
	}

	@Column(name = "is_enable", nullable = false)
	public boolean getIsEnable() {
		return this.isEnable;
	}

	public void setIsEnable(boolean isEnable) {
		this.isEnable = isEnable;
	}

	@Column(name = "shop_id", nullable = false)
	public Integer getShopId() {
		return this.shopId;
	}

	public void setShopId(Integer shopId) {
		this.shopId = shopId;
	}

	@Column(name = "name", nullable = false)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "update_time", length = 19)
	public Date getUpdateTime() {
		return this.updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	@OneToMany(fetch=FetchType.EAGER,targetEntity=FreightTemplateDestination.class,cascade={CascadeType.PERSIST})
	@JoinColumns(value={@JoinColumn(name="ft_id",referencedColumnName="id")})
	public Set<FreightTemplateDestination> getFreightTemplateDestination() {
		return freightTemplateDestination;
	}

	public void setFreightTemplateDestination(
			Set<FreightTemplateDestination> freightTemplateDestination) {
		this.freightTemplateDestination = freightTemplateDestination;
	}
	
}